import scrapy
from scrapy.linkextractors import LinkExtractor
from scrapy.spiders import CrawlSpider, Rule
from fbs.items import FbsproItem
from scrapy_redis.spiders import RedisCrawlSpider


class FbsSpider(RedisCrawlSpider):
    name = "fbs"
    # allowed_domains = ["www.xxx.com"]
    # start_urls = ["https://www.xxx.com"]
    redis_key = "sun"

    rules = (
        Rule(LinkExtractor(allow=r"Items/"), callback="parse_item", follow=True),

    )

    def parse_item(self, response):
        tr_list = response.xpath("")
        for tr in tr_list:
            new_num = tr.xpath(".//div[@class='").extract_first()
            new_title = tr.xpath(".//div[@class='").extract_first()

            item = FbsproItem()
            item["title"] = new_title
            item["new_num"] = new_num

            yield item